package com.yhsoft;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenerator {
    public static void main(String[] args) {
        String url = "jdbc:mysql:///test";
        String username = "root";
        String password = "nGOSdnBSvCvYffWH";
        String author = "yyyyyyyh";
        String outputDir = "D:\\JAVA\\CODE\\demo\\x-admin\\src\\main\\java";
        String parent = "com.yhsoft";
       // String moduleName = "sys";
        // String moduleName = "flim";
        // String moduleName = "goods";
        String moduleName = "buyer";
        String mapperLocation = "D:\\JAVA\\CODE\\demo\\x-admin\\src\\main\\resources\\mapper\\" + moduleName;
        //String tables = "g_goods_info,g_sku_info,g_good_sku,g_company_goods,g_company_sku_charge";
        // String tables = "x_company_info";
        // String tables = "baic_notice,baic_work_order_info,baic_sys_content";
        String tables = "buyer_order_card";
        // String tables = "benefit_cards_batch1,benefit_cards_batch2,benefit_cards_info,benefit_batch_goods_sku";
        // String tables = "mall_module_info";
        // String tables = "bill_saler_yszk_mx,bill_saler_yszk,bill_vender_yszk_mx,bill_sys_yfzk_mx,bill_saler_yfmx,bill_sys_yszk,bill_sys_yszk_mx,bill_sys_yfzk";
        // String tables = "buyer_user,buyer_order,buyer_cart,buyer_item,buyer_address,buyer_payment";
        // String TablePrefix = "x_";
        String TablePrefix = "buyer_";
        // String TablePrefix = "bill_";
        FastAutoGenerator.create(url,username, password)
                .globalConfig(builder -> {
                    builder.author(author) // 设置作者
                            //.enableSwagger() // 开启 swagger 模式
                            //.fileOverride() // 覆盖已生成文件
                            .outputDir(outputDir); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent(parent) // 设置父包名
                            .moduleName(moduleName) // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, mapperLocation)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude(tables) // 设置需要生成的表名
                            .addTablePrefix(TablePrefix); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
